const fs = require('fs');
const util = require('util');

const writeFile = util.promisify(fs.writeFile);

writeFile('test1.txt', 'test 1.')
  .then(() => writeFile('test2.txt', 'test 2.'))
  .then(() => writeFile('test3.txt', 'test 3.'))
  .then(() => writeFile('test4.txt', 'test 4.'))
  .then(() => writeFile('test5.txt', 'test 5.'))
  .catch((err) => console.log(err));
